<html>
<head><meta charset="utf-8"><title>meeting-2019-02-21 · t-lang/wg-unsafe-code-guidelines · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/index.html">t-lang/wg-unsafe-code-guidelines</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html">meeting-2019-02-21</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="159080908"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159080908" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159080908">(Feb 21 2019 at 16:17)</a>:</h4>
<p>So, we should have a meeting now, right?</p>



<a name="159080924"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159080924" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alan Jeffrey <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159080924">(Feb 21 2019 at 16:17)</a>:</h4>
<p><span aria-label="wave" class="emoji emoji-1f44b" role="img" title="wave">:wave:</span></p>



<a name="159080957"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159080957" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159080957">(Feb 21 2019 at 16:17)</a>:</h4>
<p>i think so</p>



<a name="159081092"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159081092" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159081092">(Feb 21 2019 at 16:19)</a>:</h4>
<p>so, do we have an agenda? /me looks at PRs</p>



<a name="159081106"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159081106" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159081106">(Feb 21 2019 at 16:19)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> I think we still don't have an mdBook deployed, do we?</p>



<a name="159081131"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159081131" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159081131">(Feb 21 2019 at 16:20)</a>:</h4>
<p>other than that, we have <a href="https://github.com/rust-rfcs/unsafe-code-guidelines/pull/83" target="_blank" title="https://github.com/rust-rfcs/unsafe-code-guidelines/pull/83">https://github.com/rust-rfcs/unsafe-code-guidelines/pull/83</a></p>



<a name="159081194"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159081194" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159081194">(Feb 21 2019 at 16:20)</a>:</h4>
<p>I think I resolved all of <span class="user-mention" data-user-id="132920">@gnzlbg</span> 's comments</p>



<a name="159081221"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159081221" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159081221">(Feb 21 2019 at 16:20)</a>:</h4>
<p>i think so too, looks good to merge</p>



<a name="159081227"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159081227" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159081227">(Feb 21 2019 at 16:20)</a>:</h4>
<p>argh, y'all, sorry, I am trying to jump on a time-sensitive bug</p>



<a name="159081236"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159081236" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159081236">(Feb 21 2019 at 16:20)</a>:</h4>
<p>so I can't really follow meeting just now</p>



<a name="159081241"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159081241" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159081241">(Feb 21 2019 at 16:20)</a>:</h4>
<blockquote>
<p>i think so too, looks good to merge</p>
</blockquote>
<p>all right, merging then</p>



<a name="159081245"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159081245" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159081245">(Feb 21 2019 at 16:20)</a>:</h4>
<p>but I think I creatd a GH_TOKEN</p>



<a name="159081249"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159081249" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159081249">(Feb 21 2019 at 16:20)</a>:</h4>
<p>in the travis setup</p>



<a name="159081254"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159081254" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159081254">(Feb 21 2019 at 16:20)</a>:</h4>
<p>so maybe in theory things will work</p>



<a name="159081258"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159081258" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159081258">(Feb 21 2019 at 16:20)</a>:</h4>
<p>if not, I can try to debug that later</p>



<a name="159081275"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159081275" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159081275">(Feb 21 2019 at 16:21)</a>:</h4>
<p>or give one of you admin access and you can do it :)</p>



<a name="159081283"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159081283" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159081283">(Feb 21 2019 at 16:21)</a>:</h4>
<p>I nominate <span class="user-mention" data-user-id="132920">@gnzlbg</span> :P</p>



<a name="159081318"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159081318" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159081318">(Feb 21 2019 at 16:21)</a>:</h4>
<p>/me has never done any of this before</p>



<a name="159081383"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159081383" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159081383">(Feb 21 2019 at 16:22)</a>:</h4>
<p>ah, I had to update the book PR, damn</p>



<a name="159081398"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159081398" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159081398">(Feb 21 2019 at 16:22)</a>:</h4>
<p>completely forgot about that</p>



<a name="159081447"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159081447" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159081447">(Feb 21 2019 at 16:22)</a>:</h4>
<p>in terms of discussions, no that much seems to happen any more</p>



<a name="159081464"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159081464" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159081464">(Feb 21 2019 at 16:23)</a>:</h4>
<p>we hit some hard questions in some cases, and it seems we mostly have consensus for the rest?</p>



<a name="159081518"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159081518" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159081518">(Feb 21 2019 at 16:23)</a>:</h4>
<p>we haven't talked at all about references to unsized types, but maybe just nobody wants to touch that^^</p>



<a name="159081671"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159081671" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159081671">(Feb 21 2019 at 16:24)</a>:</h4>
<p>I wonder if it is worth starting to write up some of the simple, uncontroversial cases (I am thinking structs, enums and the like)</p>



<a name="159081769"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159081769" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159081769">(Feb 21 2019 at 16:26)</a>:</h4>
<p>sounds good to me<br>
I also think that it might be worth writing down the cases in which representation and validity are "entangled" (where we need to fix both at the same time and can't fully split the discussion)</p>



<a name="159081833"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159081833" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159081833">(Feb 21 2019 at 16:26)</a>:</h4>
<p>which cases are you thinking of?</p>



<a name="159081890"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159081890" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159081890">(Feb 21 2019 at 16:26)</a>:</h4>
<p>i think one case was unions, whether the fields should be at offset 0 or not, depended somehow on validity</p>



<a name="159081910"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159081910" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159081910">(Feb 21 2019 at 16:27)</a>:</h4>
<p>also, is anyone volunteering for the writeup? I will likely end up doing many of the hard cases, so maybe someone else could do the easy ones?^^</p>



<a name="159081949"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159081949" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159081949">(Feb 21 2019 at 16:27)</a>:</h4>
<p>which ones do you have in mind?</p>



<a name="159082036"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159082036" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159082036">(Feb 21 2019 at 16:28)</a>:</h4>
<p>structs, arrays, ... (you know, all the types laid out side-by-side), and enums</p>



<a name="159082043"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159082043" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159082043">(Feb 21 2019 at 16:28)</a>:</h4>
<p>the ones where validity depends on the validity of fields ?</p>



<a name="159082047"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159082047" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159082047">(Feb 21 2019 at 16:28)</a>:</h4>
<blockquote>
<p>i think one case was unions, whether the fields should be at offset 0 or not, depended somehow on validity</p>
</blockquote>
<p>hm, I see. In my head we first define validity and then the rest follows, but of course defining a stricter validity is motivated by doing layout optimizations.</p>



<a name="159082139"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159082139" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159082139">(Feb 21 2019 at 16:29)</a>:</h4>
<p>so for structs, enums, arrays, tuples, vectors, (am I missing any?), I can just write a small document stating that</p>



<a name="159082148"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159082148" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159082148">(Feb 21 2019 at 16:29)</a>:</h4>
<p>for unions in particular, from all I can tell there's a fairly binary choice we can make here, with different trade-offs, and it might be worth just "documenting the controversy". I dont see data helping here.</p>



<a name="159082230"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159082230" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159082230">(Feb 21 2019 at 16:30)</a>:</h4>
<p>the issue lists structs, tuples, arrays, slices, closures, generators, SIMD vectors</p>



<a name="159082233"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159082233" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159082233">(Feb 21 2019 at 16:30)</a>:</h4>
<p>but generators are special</p>



<a name="159082281"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159082281" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159082281">(Feb 21 2019 at 16:30)</a>:</h4>
<p>I can add the part about generators to your document, if you dont feel confident explaining that</p>



<a name="159082284"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159082284" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159082284">(Feb 21 2019 at 16:30)</a>:</h4>
<p>(and we might give out an advisory to change them so they are no longer special)</p>



<a name="159082375"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159082375" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159082375">(Feb 21 2019 at 16:31)</a>:</h4>
<p>i don't feel very comfortable doing closure and generators and not doing function types there.</p>



<a name="159082438"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159082438" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159082438">(Feb 21 2019 at 16:32)</a>:</h4>
<p>but for the rest, i can word it up, and ping <span class="user-mention" data-user-id="120791">@RalfJ</span> on it</p>



<a name="159082465"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159082465" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159082465">(Feb 21 2019 at 16:32)</a>:</h4>
<p>we don't have to do all of that in the same PR</p>



<a name="159082652"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159082652" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159082652">(Feb 21 2019 at 16:34)</a>:</h4>
<p>closures are just a struct and have nothing to do with function types</p>



<a name="159082663"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159082663" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159082663">(Feb 21 2019 at 16:34)</a>:</h4>
<p>and there is nothing weird about them, unlike generators</p>



<a name="159082692"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159082692" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159082692">(Feb 21 2019 at 16:35)</a>:</h4>
<p>by closure type above I mean <code>ty::Closure</code>, which is the type of <em>the environment</em> of a closure</p>



<a name="159082697"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159082697" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159082697">(Feb 21 2019 at 16:35)</a>:</h4>
<p>I thought an empty closure coerces into a function type, so that there might be some relationship, but if we can just treat them as just structs</p>



<a name="159082698"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159082698" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159082698">(Feb 21 2019 at 16:35)</a>:</h4>
<p>the type that the <code>Fn</code> traits are implemented for</p>



<a name="159082726"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159082726" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159082726">(Feb 21 2019 at 16:35)</a>:</h4>
<p>yes it does, but empty closures are a ZST, their <code>ty::Closure</code> is like a struct with no field. validity is boring for these.</p>



<a name="159082787"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159082787" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159082787">(Feb 21 2019 at 16:36)</a>:</h4>
<p>ah, I thought the closure would be both the environment and the <code>fn</code> type, if its just the environment, then that's the same as for structs</p>



<a name="159082798"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159082798" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159082798">(Feb 21 2019 at 16:36)</a>:</h4>
<p>(as in, the environment, and the function that's called with that environment)</p>



<a name="159082812"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159082812" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159082812">(Feb 21 2019 at 16:36)</a>:</h4>
<p>the function that's called with that environment is in the vtable</p>



<a name="159082837"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159082837" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159082837">(Feb 21 2019 at 16:37)</a>:</h4>
<p>as part of the fat pointer (when using <code>dyn Fn</code>)</p>



<a name="159082858"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159082858" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159082858">(Feb 21 2019 at 16:37)</a>:</h4>
<p>or for <code>fn foo(x: impl Fn)</code>, it is handled completely statically</p>



<a name="159082898"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159082898" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159082898">(Feb 21 2019 at 16:37)</a>:</h4>
<p>can one manually modify that ?<br>
that is, create a closure, and then write a different function there ?</p>



<a name="159082951"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159082951" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159082951">(Feb 21 2019 at 16:38)</a>:</h4>
<p>no it's all generated</p>



<a name="159082970"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159082970" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159082970">(Feb 21 2019 at 16:38)</a>:</h4>
<p>with enough unstable features you can <code>impl Fn</code> for your own type though :P</p>



<a name="159083009"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159083009" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159083009">(Feb 21 2019 at 16:38)</a>:</h4>
<p>and then you "modify" that function pointer -- it'll point to the function you write as part of that <code>impl</code></p>



<a name="159083014"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159083014" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159083014">(Feb 21 2019 at 16:38)</a>:</h4>
<p>i mean, if its in the trait object vtable, then whether the closure is valid would depend on whether the vtable would be valid</p>



<a name="159083043"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159083043" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159083043">(Feb 21 2019 at 16:39)</a>:</h4>
<p>that's part of the validity of the <code>&amp;dyn Fn</code> reference</p>



<a name="159083064"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159083064" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159083064">(Feb 21 2019 at 16:39)</a>:</h4>
<p>but the environment (the <code>ty::Closure</code>) doesn't care</p>



<a name="159083220"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159083220" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159083220">(Feb 21 2019 at 16:40)</a>:</h4>
<p>i did not meant to suggest that the function is modified statically, but like, at run-time:</p>
<div class="codehilite"><pre><span></span><span class="kd">let</span><span class="w"> </span><span class="n">c</span>: <span class="kt">i32</span><span class="p">;</span><span class="w"></span>
<span class="kd">let</span><span class="w"> </span><span class="k">mut</span><span class="w"> </span><span class="n">d</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="n">x</span><span class="p">,</span><span class="w"> </span><span class="n">y</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">y</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">c</span><span class="w"> </span><span class="p">};</span><span class="w"></span>
<span class="k">fn</span> <span class="nf">bar</span><span class="p">(</span><span class="n">_env</span>: <span class="o">*</span><span class="k">const</span><span class="w"> </span><span class="p">(),</span><span class="w"> </span><span class="n">x</span>: <span class="kt">i32</span><span class="p">,</span><span class="w"> </span><span class="n">y</span>: <span class="kt">i32</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="kt">i32</span> <span class="p">{</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="n">y</span><span class="w">  </span><span class="p">}</span><span class="w"></span>
<span class="n">d</span><span class="p">.</span><span class="n">__fn_ptr</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">bar</span><span class="p">;</span><span class="w"></span>
<span class="n">d</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="w"> </span><span class="mi">3</span><span class="p">);</span><span class="w"></span>
</pre></div>



<a name="159083299"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159083299" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159083299">(Feb 21 2019 at 16:42)</a>:</h4>
<p>That's what I had in mind when I thought that the validity of a closure might depend not only on the environment being valid, but also on the function that it invokes being valid - supposing that this all could be modified at run-time.</p>



<a name="159083465"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159083465" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159083465">(Feb 21 2019 at 16:43)</a>:</h4>
<p>well first of all, not all these mismatches must be detected by the validity invariant</p>



<a name="159083489"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159083489" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159083489">(Feb 21 2019 at 16:43)</a>:</h4>
<p><code>d.__fn_ptr</code> makes no sense</p>



<a name="159083501"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159083501" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159083501">(Feb 21 2019 at 16:43)</a>:</h4>
<p>there is no function pointer there</p>



<a name="159083567"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159083567" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159083567">(Feb 21 2019 at 16:44)</a>:</h4>
<p><code>d</code> has type <code>ty::Closure[something]</code>, which is basically <code>(i32,)</code></p>



<a name="159083596"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159083596" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159083596">(Feb 21 2019 at 16:44)</a>:</h4>
<p>and the function is just a method on the closure ?</p>



<a name="159083605"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159083605" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159083605">(Feb 21 2019 at 16:44)</a>:</h4>
<p>and then there is a <code>impl Fn for [d's type] { fn __call(self, x, y) { x + y + self.0 } }</code></p>



<a name="159083653"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159083653" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159083653">(Feb 21 2019 at 16:45)</a>:</h4>
<p>but just like <code>Vec</code>'s dont contain a function pointer for the <code>impl Debug for Vec</code>, <code>d</code> will not contain a fn ptr for this <code>impl Fn</code></p>



<a name="159083761"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159083761" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159083761">(Feb 21 2019 at 16:46)</a>:</h4>
<p>when you do <code>let d: &amp;dyn Fn = &amp;d</code>, then the same thing happens as when you do <code>let v: &amp;dyn Debug = vec![0]</code></p>



<a name="159083785"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159083785" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159083785">(Feb 21 2019 at 16:46)</a>:</h4>
<p>that makes sense, i though this was implemented differently:</p>
<div class="codehilite"><pre><span></span><span class="k">fn</span> <span class="nf">__closure_fn</span><span class="p">(...)</span><span class="w"> </span>-&gt; <span class="p">...</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="k">type</span> <span class="nc">Closure</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="kt">i32</span><span class="p">,</span><span class="w"> </span><span class="k">fn</span><span class="p">(...)</span><span class="w"> </span>-&gt; <span class="p">...)</span><span class="w"></span>
<span class="kd">let</span><span class="w"> </span><span class="n">c</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">Closure</span><span class="p">(</span><span class="n">c</span><span class="p">,</span><span class="w"> </span><span class="n">__closure_fn</span><span class="p">);</span><span class="w"></span>
</pre></div>



<a name="159083800"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159083800" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159083800">(Feb 21 2019 at 16:46)</a>:</h4>
<p>a vtable gets created, with fn ptr to the functions implementing that trait for the given type, and the vtable ptr gets paired up with the ptr to the element of the type implementing the trait</p>



<a name="159083836"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159083836" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159083836">(Feb 21 2019 at 16:47)</a>:</h4>
<p>well that fhn ptr would be useless if we end up using static dispatch</p>



<a name="159083838"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159083838" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159083838">(Feb 21 2019 at 16:47)</a>:</h4>
<p>gotcha, i was confused</p>



<a name="159083849"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159083849" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159083849">(Feb 21 2019 at 16:47)</a>:</h4>
<p>also this is much nicer becuase there dynamically dispatched closures basically are just an instance of the general <code>dyn Trait</code> mechanism :D</p>



<a name="159083851"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159083851" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159083851">(Feb 21 2019 at 16:47)</a>:</h4>
<p>(I love this)</p>



<a name="159083866"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159083866" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159083866">(Feb 21 2019 at 16:47)</a>:</h4>
<p>yes, i though that it wouldn't matter much because llvm could eliminate it, but that is more elegant</p>



<a name="159083888"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159083888" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159083888">(Feb 21 2019 at 16:47)</a>:</h4>
<p>we dont rely on LLVM if we can help it :D</p>



<a name="159083933"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159083933" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159083933">(Feb 21 2019 at 16:48)</a>:</h4>
<p>well that simplifies validity of closures, its just the same as for structs</p>



<a name="159083946"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159083946" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159083946">(Feb 21 2019 at 16:48)</a>:</h4>
<p>exactly</p>



<a name="159083949"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159083949" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159083949">(Feb 21 2019 at 16:48)</a>:</h4>
<p>so I can draft that</p>



<a name="159083956"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159083956" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159083956">(Feb 21 2019 at 16:48)</a>:</h4>
<p>awesome :)</p>



<a name="159083976"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21/near/159083976" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/meeting-2019-02-21.html#159083976">(Feb 21 2019 at 16:48)</a>:</h4>
<p>and with that, I have to leave... thanks all!</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>